Create 0496-next-greater-element-I.md #1534
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue
Fixes #1481
Description
The next greater element of some element
x
in an array is the first greater element that is to the right ofx
in the same array.You are given two distinct 0-indexed integer arrays
nums1
andnums2
, wherenums1
is a subset ofnums2
.For each
0 <= i < nums1.length
, find the indexj
such thatnums1[i] == nums2[j]
and determine the next greater element ofnums2[j]
innums2
. If there is no next greater element, then the answer for this query is-1
.Return an array
ans
of lengthnums1.length
such thatans[i]
is the next greater element as described above.[Please include a brief description of the changes or features added]
Type of PR
Screenshots / Videos (if applicable)
[Attach any relevant screenshots or videos demonstrating the changes]
Checklist
Additional Context
[Include any additional information or context that might be helpful for reviewers.]
Resources for Guidance
Please read the following resources before submitting your contribution:
Resources for DSA Features on Our Site:
Contribution Guidelines
Thank you for considering contributing to our project! To ensure smooth collaboration and effective contribution management, please adhere to the following guidelines:
Issue Creation
Contribution Levels
Basic Contributions:
Acknowledging Hard Work:
Feature Additions and Component Work:
Level Definitions
We look forward to your contributions and appreciate your effort in helping us improve the project!